import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialQuery, MaterialVO, MaterialForm, HeuinsWcie, huonseug } from '@/api/operates/material/types';

/**
 * 素材列表
 * @param query
 * @returns
 */
export const listMaterial = (query: MaterialQuery): AxiosPromise<TableInfoVO<MaterialVO>> => {
  return request({
    url: '/material/list',
    method: 'get',
    params: query
  });
};

/**
 * 素材详情
 * @param id
 * @returns
 */
export const getMaterial = (id: string | number): AxiosPromise<MaterialVO> => {
  return request({
    url: `/material/${id}`,
    method: 'get'
  });
};

/**
 * 素材添加
 * @param data
 * @returns
 */
export const addMaterial = (data: MaterialForm) => {
  return request({
    url: '/material',
    method: 'post',
    data: data
  });
};

/**
 * 素材编辑
 * @param data
 * @returns
 */
export const updateMaterial = (data: MaterialForm) => {
  return request({
    url: '/material',
    method: 'put',
    data: data
  });
};

/**
 * 素材上架下架-审核
 * @param id
 * @returns
 */
export const enableMaterial = (id: string | number) => {
  return request({
    url: `/material/enable/${id}`,
    method: 'put'
  });
};

/**
 * 素材删除
 * @param id
 * @returns
 */
export const delMaterial = (ids: string | number) => {
  return request({
    url: `/material/${ids}`,
    method: 'delete'
  });
};

/**
 * 素材内容管理
 */
export const huonsetico = (materialId: string | number) => {
  return request({
    url: `/material/content/${materialId}`,
    method: 'GET'
  });
};

/**
 * 素材内容添加
 * @param data
 * @returns
 */
export const addContent = (data: HeuinsWcie) => {
  return request({
    url: '/material/content',
    method: 'post',
    data: data
  });
};

/**
 * 素材内容删除
 * @param id
 * @returns
 */
export const delContent = (ids: string | number) => {
  return request({
    url: `/material/content/${ids}`,
    method: 'delete'
  });
};

/**
 * 素材内容排序
 */
export const demuinsesort = (ids: Array<string | number>) => {
  return request({
    url: `/material/content/sort/${ids}`,
    method: 'PUT'
  });
};

/**
 * 佐糖API的创建抠图任务
 */
export const putccanel = (data: huonseug) => {
  return request({
    url: 'https://techsz.aoscdn.com/api/tasks/visual/segmentation',
    method: 'POST',
    data: data
  });
};

/**
 * 佐糖API的抠图完成
 */
export const muionsef = (task_id: string | number) => {
  return request({
    url: `https://techsz.aoscdn.com/api/tasks/visual/segmentation/${task_id}`,
    method: 'GET'
  });
};
